package com.ease.common.vo.editor;

import java.beans.PropertyEditorSupport;

import com.ease.common.util.Detect;

public abstract class AbstractObjectEditor<T> extends PropertyEditorSupport {

	public abstract T editAsText(String text);

	@SuppressWarnings("unchecked")
	public T getObject() {
		return (T) (getValue());
	}

	public void setAsText(String text) {
		if (Detect.notEmpty(text)) {
			T t = editAsText(text);
			setValue(t);
		} else {
			setValue((T) null);
		}
	}
}
